//
//  STEmailApi.swift
//  Story
//
//  Created by 汤泽川 on 2019/4/2.
//  Copyright © 2019 汤泽川. All rights reserved.
//

import Foundation

class STEmailApi {
    static func sendEmail(email : String, result : @escaping (_ error : STError?) -> Void) {
        let request = STRequest<ResponseModel<String> >()
        request.requestPath = "/users/get_verify_code"
        request.baseUrl = "http://tzcccy.cn/api"
        request.requestParam = ["email" : email]
        request.sendRequest { (state) in
            switch state {
            case .success(let data):
                if data.status != 0 {
                    result(STError(code: data.status, reason: data.message, errorType: .customError))
                } else {
                    result(nil)
                }
            case .fail(let error):
                result(error)
            }
        }
    }
}
